<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>通用 | AchievementDoc</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="Achievement.svg">
    <meta name="description" content="BDS llse plugins Achievement">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/AchievementDocs/assets/css/0.styles.faa91785.css" as="style"><link rel="preload" href="/AchievementDocs/assets/js/app.edb454d1.js" as="script"><link rel="preload" href="/AchievementDocs/assets/js/2.7abd1384.js" as="script"><link rel="preload" href="/AchievementDocs/assets/js/12.3037f7c6.js" as="script"><link rel="preload" href="/AchievementDocs/assets/js/17.f21db974.js" as="script"><link rel="prefetch" href="/AchievementDocs/assets/js/10.e2c0d9c4.js"><link rel="prefetch" href="/AchievementDocs/assets/js/11.68f630cf.js"><link rel="prefetch" href="/AchievementDocs/assets/js/13.dee9ab6c.js"><link rel="prefetch" href="/AchievementDocs/assets/js/14.b289dab8.js"><link rel="prefetch" href="/AchievementDocs/assets/js/15.43d0b29e.js"><link rel="prefetch" href="/AchievementDocs/assets/js/16.20b317fe.js"><link rel="prefetch" href="/AchievementDocs/assets/js/18.21f52500.js"><link rel="prefetch" href="/AchievementDocs/assets/js/19.b4007424.js"><link rel="prefetch" href="/AchievementDocs/assets/js/20.71325f04.js"><link rel="prefetch" href="/AchievementDocs/assets/js/21.5a949711.js"><link rel="prefetch" href="/AchievementDocs/assets/js/22.1a2cf411.js"><link rel="prefetch" href="/AchievementDocs/assets/js/23.0dcec73e.js"><link rel="prefetch" href="/AchievementDocs/assets/js/24.a28a9d80.js"><link rel="prefetch" href="/AchievementDocs/assets/js/25.d9eb6bef.js"><link rel="prefetch" href="/AchievementDocs/assets/js/26.c62ce9be.js"><link rel="prefetch" href="/AchievementDocs/assets/js/27.003d037b.js"><link rel="prefetch" href="/AchievementDocs/assets/js/28.738a65b9.js"><link rel="prefetch" href="/AchievementDocs/assets/js/29.ad6cac79.js"><link rel="prefetch" href="/AchievementDocs/assets/js/3.f6c8ad74.js"><link rel="prefetch" href="/AchievementDocs/assets/js/30.a8e62aa4.js"><link rel="prefetch" href="/AchievementDocs/assets/js/31.6a208574.js"><link rel="prefetch" href="/AchievementDocs/assets/js/32.834105cd.js"><link rel="prefetch" href="/AchievementDocs/assets/js/33.ed913bbc.js"><link rel="prefetch" href="/AchievementDocs/assets/js/34.312d58db.js"><link rel="prefetch" href="/AchievementDocs/assets/js/35.22689fc9.js"><link rel="prefetch" href="/AchievementDocs/assets/js/36.f27625a2.js"><link rel="prefetch" href="/AchievementDocs/assets/js/37.d128139d.js"><link rel="prefetch" href="/AchievementDocs/assets/js/38.b602055e.js"><link rel="prefetch" href="/AchievementDocs/assets/js/39.e9af109c.js"><link rel="prefetch" href="/AchievementDocs/assets/js/4.2aefbe48.js"><link rel="prefetch" href="/AchievementDocs/assets/js/40.73f99be4.js"><link rel="prefetch" href="/AchievementDocs/assets/js/41.0511e1a1.js"><link rel="prefetch" href="/AchievementDocs/assets/js/42.e43479cb.js"><link rel="prefetch" href="/AchievementDocs/assets/js/43.1ab7be64.js"><link rel="prefetch" href="/AchievementDocs/assets/js/44.373a49a0.js"><link rel="prefetch" href="/AchievementDocs/assets/js/5.f7715398.js"><link rel="prefetch" href="/AchievementDocs/assets/js/6.b0416276.js"><link rel="prefetch" href="/AchievementDocs/assets/js/7.167c7f4c.js"><link rel="prefetch" href="/AchievementDocs/assets/js/8.a5598e6f.js"><link rel="prefetch" href="/AchievementDocs/assets/js/9.b58c1acd.js">
    <link rel="stylesheet" href="/AchievementDocs/assets/css/0.styles.faa91785.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><!----> <header class="navbar"><div class="navbar-container"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/AchievementDocs/" class="home-link router-link-active"><!----> <span class="site-name">AchievementDoc</span></a> <div class="links"><div class="search-box"><input aria-label="Search" placeholder="Search" autocomplete="off" spellcheck="false" value=""> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="search-icon"><path d="M21.7,20.3L18,16.6c1.2-1.5,2-3.5,2-5.6c0-5-4-9-9-9c-5,0-9,4-9,9c0,5,4,9,9,9c2.1,0,4.1-0.7,5.6-2l3.7,3.7c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3C22.1,21.3,22.1,20.7,21.7,20.3zM4,11c0-3.9,3.1-7,7-7c3.9,0,7,3.1,7,7c0,1.9-0.8,3.7-2,4.9c0,0,0,0,0,0s0,0,0,0c-1.3,1.3-3,2-4.9,2C7.1,18,4,14.9,4,11z"></path></svg> <span class="search-command-wrapper search-command"><span class="search-command-char">⌘</span> <span class="search-command-char">K</span></span> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/AchievementDocs/" class="vp-link nav-link">
  Home
  </a></div><div class="nav-item"><a href="/AchievementDocs/guide.html" class="vp-link nav-link">
  指南🧭
  </a></div><div class="nav-item"><a href="/AchievementDocs/question.html" class="vp-link nav-link">
  Q&amp;A
  </a></div><div class="nav-item"><a href="https://github.com/246859/Achievement.git" target="_blank" class="vp-link external nav-link">
  Github
  <!----> </a></div><div class="nav-item"><a href="https://github.com/246859/AchievementDoc" target="_blank" class="vp-link external nav-link">
  编辑✍
  <!----> </a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="站点" class="dropdown-title"><span class="title">站点</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="icon-down"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></button> <button type="button" aria-label="站点" class="mobile-dropdown-title"><span class="title">站点</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="arrow-icon"><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://246859.github.io/AchievementDocs/" target="_blank" class="vp-link external nav-link">
  国外
  <!----> </a></li><li class="dropdown-item"><!----> <a href="https://float1024.gitee.io/achievementdocs/" target="_blank" class="vp-link external nav-link">
  国内
  <!----> </a></li></ul></div></div> <div class="VPNavBarAppearance appearance" data-v-19d27b0e><button type="button" aria-label="toggle dark mode" class="vt-switch vt-switch-appearance" data-v-19d27b0e><span class="vt-switch-check"><span class="vt-switch-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="vt-switch-appearance-sun"><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path> <path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path> <path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path> <path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path> <path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path> <path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path> <path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path> <path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path> <path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="vt-switch-appearance-moon"><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg></span></span></button></div> <!----></nav></div></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/AchievementDocs/" class="vp-link nav-link">
  Home
  </a></div><div class="nav-item"><a href="/AchievementDocs/guide.html" class="vp-link nav-link">
  指南🧭
  </a></div><div class="nav-item"><a href="/AchievementDocs/question.html" class="vp-link nav-link">
  Q&amp;A
  </a></div><div class="nav-item"><a href="https://github.com/246859/Achievement.git" target="_blank" class="vp-link external nav-link">
  Github
  <!----> </a></div><div class="nav-item"><a href="https://github.com/246859/AchievementDoc" target="_blank" class="vp-link external nav-link">
  编辑✍
  <!----> </a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="站点" class="dropdown-title"><span class="title">站点</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="icon-down"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></button> <button type="button" aria-label="站点" class="mobile-dropdown-title"><span class="title">站点</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="arrow-icon"><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://246859.github.io/AchievementDocs/" target="_blank" class="vp-link external nav-link">
  国外
  <!----> </a></li><li class="dropdown-item"><!----> <a href="https://float1024.gitee.io/achievementdocs/" target="_blank" class="vp-link external nav-link">
  国内
  <!----> </a></li></ul></div></div> <div class="VPNavBarAppearance appearance" data-v-19d27b0e><button type="button" aria-label="toggle dark mode" class="vt-switch vt-switch-appearance" data-v-19d27b0e><span class="vt-switch-check"><span class="vt-switch-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="vt-switch-appearance-sun"><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path> <path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path> <path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path> <path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path> <path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path> <path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path> <path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path> <path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path> <path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="vt-switch-appearance-moon"><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg></span></span></button></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><a href="/AchievementDocs/view/config/" class="sidebar-heading clickable"><span>配置教程⚙️</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="arrow-icon"><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></a> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><a href="/AchievementDocs/view/diy/" class="sidebar-heading clickable"><span>自定义教程🗜️</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="arrow-icon"><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></a> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><a href="/AchievementDocs/view/api/" class="sidebar-heading clickable router-link-active open"><span>API导出🔌</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="arrow-icon"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></a> <ul class="sidebar-links sidebar-group-items"><li><a href="/AchievementDocs/view/api/0.common.html" aria-current="page" class="active sidebar-link">通用</a></li><li><a href="/AchievementDocs/view/api/1.plData.html" class="sidebar-link">玩家数据</a></li><li><a href="/AchievementDocs/view/api/2.entryData.html" class="sidebar-link">词条数据</a></li><li><a href="/AchievementDocs/view/api/3.logic.html" class="sidebar-link">自定义成就</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><a href="/AchievementDocs/view/entry/" class="sidebar-heading clickable"><span>词条百科📚</span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="arrow-icon"><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></a> <!----></section></li></ul> </aside> <main class="page viewapi0.common.html"> <div class="theme-default-content vp-doc content__default"><h1 id="通用"><a href="#通用" class="header-anchor">#</a> 通用</h1> <div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>插件核心的初始化过程是异步的，不过接口导出是同步的，可能会出现核心还未初始化完，但访问了接口这种情况。</p></div> <h2 id="命名空间"><a href="#命名空间" class="header-anchor">#</a> 命名空间</h2> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">const</span> namespace <span class="token operator">=</span> <span class="token string">&quot;Achievement&quot;</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="获取运行时配置"><a href="#获取运行时配置" class="header-anchor">#</a> 获取运行时配置</h2> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token function">getConfig</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>返回值：<code>Object</code> - 插件的运行时配置对象</li> <li>参数：无</li></ul> <h2 id="渲染模板"><a href="#渲染模板" class="header-anchor">#</a> 渲染模板</h2> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token function">renderTemplate</span><span class="token punctuation">(</span>str<span class="token punctuation">,</span> <span class="token operator">...</span>args<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>返回值：<code>string</code> - 渲染后的一个字符串</li> <li>参数：
<ul><li><code>str: string</code>  - 符合模板语法的字符串</li> <li><code>args: any[]</code>  - 插值参数</li></ul></li></ul> <h2 id="获取核心的加载状态"><a href="#获取核心的加载状态" class="header-anchor">#</a> 获取核心的加载状态</h2> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token function">isAppLoaded</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>返回值：<code>boolen</code> - 核心插件是否完全初始化完成</li> <li>参数：无</li></ul> <div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>由于LL RPC不支持Promise对象，部分情况需要开发者自行处理。</p></div> <h2 id="等待加载示例"><a href="#等待加载示例" class="header-anchor">#</a> 等待加载示例</h2> <p>倘若想要等待核心插件某些配置项加载完毕再初始化插件（例如等待核心插件配置文件加载完毕，再读取其语言配置项），可以按照如下的例子进行简单的处理。</p> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token parameter">time</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> time<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">waitting</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">let</span> maxCount <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">isAppLoaded</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">++</span>maxCount<span class="token operator">&gt;=</span><span class="token number">5</span><span class="token punctuation">)</span> <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Error</span><span class="token punctuation">(</span><span class="token string">&quot;等待超时&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token function">waitting</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">res</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
    logger<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">&quot;核心加载成功&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catcah</span><span class="token punctuation">(</span><span class="token parameter">err</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
    logger<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">&quot;核心加载超时: &quot;</span><span class="token punctuation">,</span>err<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div></div> <footer class="page-edit"><!----> <div class="last-updated"><svg width="1em" height="1em" viewBox="0 0 24 24" class="last-updated-icon"><path d="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1a6.887 6.887 0 0 0 0 9.8c2.73 2.7 7.15 2.7 9.88 0c1.36-1.35 2.04-2.92 2.04-4.9h2c0 1.98-.88 4.55-2.64 6.29c-3.51 3.48-9.21 3.48-12.72 0c-3.5-3.47-3.53-9.11-.02-12.58a8.987 8.987 0 0 1 12.65 0L21 3v7.12M12.5 8v4.25l3.5 2.08l-.72 1.21L11 13V8h1.5z" fill="currentColor"></path></svg> <span class="prefix">最后更新于: </span> <span class="time">10/18/2022, 9:58:41 AM</span></div></footer> <div class="page-nav"><div class="inner"><a href="/AchievementDocs/view/diy/5.diyImg.html" class="vp-link prev"><span>←</span>
  自定义图标
  <span><br> <span class="prev-link">/view/diy/5.diyImg.html</span></span></a> <a href="/AchievementDocs/view/api/1.plData.html" class="vp-link next">
  玩家数据
  <span>
        →
        <br> <span class="next-link">/view/api/1.plData.html</span></span></a></div></div> </main> <div class="sticker vuepress-toc"><div class="on-this-page">ON THIS PAGE</div> <div class="vuepress-toc-item vuepress-toc-h2 active"><a href="#命名空间" title="命名空间">命名空间</a></div><div class="vuepress-toc-item vuepress-toc-h2"><a href="#获取运行时配置" title="获取运行时配置">获取运行时配置</a></div><div class="vuepress-toc-item vuepress-toc-h2"><a href="#渲染模板" title="渲染模板">渲染模板</a></div><div class="vuepress-toc-item vuepress-toc-h2"><a href="#获取核心的加载状态" title="获取核心的加载状态">获取核心的加载状态</a></div><div class="vuepress-toc-item vuepress-toc-h2"><a href="#等待加载示例" title="等待加载示例">等待加载示例</a></div></div></div><div class="global-ui"><!----></div></div>
    <script src="/AchievementDocs/assets/js/app.edb454d1.js" defer></script><script src="/AchievementDocs/assets/js/2.7abd1384.js" defer></script><script src="/AchievementDocs/assets/js/12.3037f7c6.js" defer></script><script src="/AchievementDocs/assets/js/17.f21db974.js" defer></script>
  </body>
</html>
